//*************************************************************************************
/** \file  avr_adc.h
 *    FIXME: This file needs a comment which describes what's in here. 
 *
 *  Revisions:
 *    \li  00-00-00  The Big Bang occurred, followed by the invention of waffles
 *
 *  License
 *    This file copyright 2007-2012 by somebody. It is released under the Lesser GNU
 *    public license, version 2. It is intended for educational use only, but the
 *    user is free to use it for any purpose permissible under the LGPL. The author
 *    has no control over the use of this file and cannot take any responsibility
 *    for any consequences of this use. 
 */
//*************************************************************************************

/// This define prevents this .h file from being included more than once in a .cc file
#ifndef _AVR_ADC_H_
#define _AVR_ADC_H_


//=====================================================================================
/** This class should run the A/D converter on an AVR processor. 
 *  TODO: It should have some better comments. Handing in a Doxygen file with only this
 *  would not look good. 
 */

class avr_adc
{
	protected:
		// The ADC class needs a pointer to the serial port used to say hello. This 
		// base class pointer could also be used for a wireless radio 
		base_text_serial* ptr_to_serial;

		// This counter counts the number of times the A/D has been read. It is only 
		// in the class as a demonstration variable, and you may take it out
		uint8_t runs;

	public:
		// The constructor just says hello at the moment, using the serial port which
		// is specified in the pointer given to it
		avr_adc (base_text_serial*);

		// This could be a function to read one channel once, returning the result as
		// an unsigned integer. The parameter is the channel number 
		uint16_t read_once (uint8_t);

		// This could be a function to read a set of several channels into an array. 
		// The parameters are starting and ending channel numbers
		void read_several (uint8_t, uint8_t);

		/** This is an example of a method which allows a function outside the avr_adc
		 *  class (in this case, the "<<" operator) to get the value of a class member
		 *  variable. It must be used to access "runs" which is protected. This method
		 *  is completely defined right here in the *.h file, so it doesn't need to be
		 *  in the *.cc file at all. This technique is only for very simple methods.
		 *  @return The current value of the number of runs counter
		 */
		uint8_t get_runs (void) { return (runs); }
    };


//-------------------------------------------------------------------------------------
/** This operator prints an A/D converter on a text serial device. You may decide what
 *  is most useful to print; it should be some information about how the A/D converter
 *  is set up, what it's doing, current readings, or something like that. 
 */

base_text_serial& operator<< (base_text_serial&, avr_adc&);

#endif // _AVR_ADC_H_
